Array.prototype.ma_reduce = function (fn, val) {
  let total = val;
  for (let [index, item] of this.entries()) {
    total = fn(total, item, index, this);
  }
  return total;
};

const arr = [1, 2, 3, 4, 5];
const num = arr.ma_reduce((total, item, index, arr) => {
  return (total += item);
}, 0);

console.log(num);
